<template>
  <view class="content" :style="{ height: sizeInfo.height + 'px' }">
    <view class="topSty">
      <view class="subsection">
        <u-subsection
          :style="{ width: '100%' }"
          :list="sectionTabs"
          :current="curNow"
          active-color="#1784FC "
          @change="sectionChange"
        ></u-subsection>
      </view>
      <view class="top search">
        <u-search
          placeholder="请输入职位名称"
          shape="round"
          v-model="keyword"
          @custom="searchClick()"
          @search="searchClick()"
        ></u-search>
      </view>
    </view>
    <view v-if="listData.length > 0" class="flex-wrp">
      <view v-for="(item, index) in listData" :key="index">
        <view class="list">
          <view class="l_left" mode="heightFix">
            <text class="enterpriseName">{{item.enterpriseName}}</text>
            <view class="l_middle">
              <text class="postion">{{ item.positionName }}</text>
              <text class="salary"
                >{{ item.positionSalary
                }}{{ item.positionSalary == "面议" ? "" : 元
                }}{{
                  item.positionSalary == "面议"
                    ? ""
                    : curNow == 0
                    ? "/月"
                    : "/" + item.recruitUnit
                }}</text
              >
            </view>
            <text class="position_desc">职位描述：{{item.positionDesc}}</text>
            <text class="position_desc">联系人：{{item.linkName}}</text>
            <text class="position_desc">联系电话：{{item.linkPhone}}</text>
            <text class="period"
              >{{ item.recruitBegindate }} ~ {{ item.recruitEnddate }}</text
            >
          </view>
          <view class="line"></view>
        </view>
      </view>
      <!-- <u-toast ref="uToast" /> -->
      <!-- <u-loadmore
        v-if="listData.length > 3"
        style="loadmore"
        :status="status"
        :icon-type="iconType"
        :load-text="loadText"
      /> -->
    </view>
    <view v-else>
      <view class="tkxxBox">
        <image :src="msg" class="tkxxPic" />
      </view>
      <view class="contentTxt">未发现有数据~</view>
    </view>
  </view>
</template>

<script>
import api from "@/common/utils/api"; //接口
export default {
  data() {
    return {
      student: uni.getStorageSync("student"),
      sizeInfo: {
        height: 0, //滚动区域高度
      },
      msg: "/static/image/msg.png",
      keyword: "",
      sectionTabs: [
        {
          name: "全职职能",
          status: 0,
        },
        {
          name: "零工职能",
          status: 1,
        },
      ],
      curNow: 0,
      current: 0,
      // page: 1, //0开始
      // total: 0, //总页数
      listData: [],
      /* 上拉刷新,下拉加载 */
      // loadingType: 0,
      status: "loadmore",
      // iconType: "circle",
      // loadText: {
      //   loadmore: "上拉加载更多",
      //   loading: "加载中",
      //   nomore: "没有更多了",
      // },
    };
  },
  onPullDownRefresh() {
    //下拉刷新
    // this.page = 1;
    // this.loadingType = 0;
    // this.getRecruitListData(true);
  },
  onReachBottom() {
    //上拉加载更多
    // if (this.page >= this.total) {
    //   this.loadingType = 2;
    //   this.statusChange(3);
    //   return false;
    // } else {
    //   this.loadingType = 0;
    //   this.statusChange(1);
    //   this.getMoreListData();
    // }
  },
  created() {},
  onLoad() {},
  onShow() {
    let userInfo = uni.getStorageSync("userInfo");
    if (userInfo) {
      if (this.curNow == 0) {
        this.getRecruitListData();
      } else {
        this.getOddListData();
      }
    } else {
      uni.showToast({
        title: "未获取到用户信息！",
        icon: "none",
      });
      return;
    }
  },
  mounted() {
    this.createds();
  },
  methods: {
    searchClick() {
      if (this.curNow == 0) {
        this.getRecruitListData();
      } else {
        this.getOddListData();
      }
    },
    sectionChange(index) {
      this.curNow = index;
      if (this.curNow == 0) {
        this.getRecruitListData();
      } else {
        this.getOddListData();
      }
    },
    // change(index) {
    //   uni.showLoading({
    //     title: "加载中",
    //   });
    //   this.tabStatus = this.tabs[index].status;
    //   this.listData = [];
    //   if (this.curNow == 0) {
    //     this.getRecruitListData();
    //   } else {
    //     this.getOddListData();
    //   }
    // },
    // editClick(item) {
    //   if (this.curNow == 0) {
    //     this.$u.route({
    //       url: "pages/mine/recruitEdit",
    //       params: { row: JSON.stringify(item), editType: 0 },
    //     });
    //   } else {
    //     this.$u.route({
    //       url: "pages/mine/oddEdit",
    //       params: { row: JSON.stringify(item), editType: 0 },
    //     });
    //   }
    // },
    // againRelease(item) {
    //   if (this.curNow == 0) {
    //     this.$u.route({
    //       url: "pages/mine/recruitEdit",
    //       params: { row: JSON.stringify(item), editType: 1 },
    //     });
    //   } else {
    //     this.$u.route({
    //       url: "pages/mine/oddEdit",
    //       params: { row: JSON.stringify(item), editType: 1 },
    //     });
    //   }
    // },
    // deleteClick(item) {
    //   let that = this;
    //   uni.showModal({
    //     title: "提示",
    //     content: "确定删除该职位信息？一同发布的其他职位信息也会被删除！",
    //     success: function (res) {
    //       if (res.confirm) {
    //         if (that.curNow == 0) {
    //           let par = {
    //             recruitId: item.recruitId,
    //             // positionId: item.positionId,
    //             recruitStatus: 4,
    //           };
    //           api.recruitUpdate(par).then((res) => {
    //             if (res.success) {
    //               uni.showToast({
    //                 title: "删除成功",
    //                 icon: "none",
    //                 mask: true,
    //               });
    //               that.getRecruitListData();
    //             } else {
    //               uni.showToast({
    //                 title: "操作失败！",
    //                 icon: "none",
    //                 mask: true,
    //               });
    //             }
    //             uni.hideLoading();
    //           });
    //         } else {
    //           let par = {
    //             recruitId: item.recruitId,
    //             // positionId: item.positionId,
    //             recruitStatus: 4,
    //           };
    //           api.zeroUpdate(par).then((res) => {
    //             if (res.success) {
    //               uni.showToast({
    //                 title: "删除成功",
    //                 icon: "none",
    //                 mask: true,
    //               });
    //               that.getOddListData();
    //             } else {
    //               uni.showToast({
    //                 title: "操作失败！",
    //                 icon: "none",
    //                 mask: true,
    //               });
    //             }
    //             uni.hideLoading();
    //           });
    //         }
    //       } else if (res.cancel) {
    //         // console.log('用户点击取消')
    //       }
    //     },
    //   });
    // },
    createds() {
      // if (this.ticker) {
      //   //这一段是防止进入页面出去后再进来计时器重复启动
      //   clearInterval(this.ticker);
      // }
      // this.beginTimer(); //启动计时器减指定字段的时间
    },
    // 全职职能列表
    getRecruitListData(isPullDown) {
      let par = {};
      par = {
        //1、待审核、2、审核成功、3、审核失败、4、已删除、5、已下架
        status: "2",
        positionName: this.keyword,
      };
      let userInfo = uni.getStorageSync("userInfo");
      par.submitOpenId = userInfo.openid;
      uni.showLoading()
      api.findAllRecruitJobPosition(par).then((res) => {
        if (res.success) {
          let listData = res.data || [];
          this.listData = listData;
        }
        uni.hideLoading();
      });
    },
    // 零工职能列表
    getOddListData(isPullDown) {
      let par = {};
      let url = "";
      par = {
        //1、待审核、2、审核成功、3、审核失败、4、已删除、5、已下架
        status: "2",
        positionName: this.keyword,
      };
      let userInfo = uni.getStorageSync("userInfo");
      par.submitOpenId = userInfo.openid;
      uni.showLoading()
      api.findAllOddJobPosition(par).then((res) => {
        if (res.success) {
          let listData = res.data || [];
          this.listData = listData;
        }
        uni.hideLoading();
      });
    },
    // statusChange(index) {
    //   this.status =
    //     index == 0
    //       ? "loadmore"
    //       : index == 1
    //       ? "loading"
    //       : index == 2
    //       ? "loadmore"
    //       : "nomore";
    // },
  },
};
</script>

<style scoped>
.content {
  display: flex;
  flex-direction: column;
  background: #f7f7f7;
}
.topSty {
  width: 100%;
  position: fixed;
  z-index: 99;
  top: 0px;
  left: 0;
  right: 0;
  background: #fff;
}
.top {
  display: flex;
  flex-direction: row;
  margin: 20rpx 50rpx;
  align-items: center;
  justify-content: space-between;
}
.search {
  padding: 0 0 0 10px;
  border-radius: 30px;
}
.subsection {
  margin-left: 6%;
  margin-right: 6%;
  margin-top: 10px;
}
.row {
  flex-direction: row;
  display: flex;
}
.center {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.flex-wrp {
  /* overflow-y: scroll; */
  flex: 1;
  padding: 10px 20px 60px 10px;
  margin-top: 140rpx;
}
.list {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin: 10px 0;
  /* -moz-box-shadow: -1px 1px 11px rgba(32, 32, 32, 0.07);
  -webkit-box-shadow: -1px 1px 11px rgba(32, 32, 32, 0.07);
  box-shadow: -1px 1px 11px rgba(32, 32, 32, 0.07); */
  position: relative;
  border-bottom: 4rpx solid #efefef;
}
.l_left {
  /* height: 210rpx; */
  /* max-width: 250rpx; */
  padding-top: 20rpx;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.enterpriseName{
  
}
.l_middle{
  margin-top: 30rpx;
}
.salary {
  margin-left: 30rpx;
}
.position_desc{
  margin-top: 30rpx;
  /* text-overflow:ellipsis;
overflow:hidden;
display:-webkit-box;
-webkit-line-clamp:3;	
-webkit-box-orient:vertical; */
}
.period {
  margin-top: 30rpx;
  margin-bottom: 30rpx;
}
.r_item {
  margin: 5px 0;
  display: inline-grid;
  width: 100rpx;
  align-items: center;
}
.tkxxBox {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 50%;
  margin-bottom: 28rpx;
}
.tkxxPic {
  width: 54%;
  height: 280rpx;
  display: block;
}
.contentTxt {
  text-align: center;
  font-size: 28rpx;
  font-weight: bold;
  color: #333333;
}
.postion {
  font-weight: 700;
}
.salary {
  color: red;
}
</style>